/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package gui;

import stendcontrol.Configurator;
import stendcontrol.DataExtract;
import stendcontrol.StendLogger;
import stendcontrol.TransmitListener;

/**
 *
 * @author minaev
 */
public class SensorSlidePlotterModel implements TransmitListener {

    private JSlidePlotter[] slides =
            new JSlidePlotter[Configurator.COUNT_SENSOR];

    /*public SensorSlidePlotterModel(JSlidePlotter[] slides) {
     if (slides.length == Configurator.COUNT_SENSOR) {
     this.slides = slides;
     }else{
     StendLogger.log(StendLogger.MSG_ERROR, "Bad size Slide array: "+
     slides.length+" Need size: "+Configurator.COUNT_SENSOR);
     }
     }*/
    public SensorSlidePlotterModel(JSlidePlotter... slides) {
        if (slides.length == Configurator.COUNT_SENSOR) {
            this.slides = slides;
        } else {
            StendLogger.log(StendLogger.MSG_ERROR, "Bad size Slide array: "
                    + slides.length + " Need size: " + Configurator.COUNT_SENSOR);
        }
    }

    @Override
    public void transmitPerformed(byte[] buf, int len) {
        if (buf[0] >> 4 == 1) {
            for (int i = 0; i < slides.length; i++) {
                slides[i].addValue(DataExtract.getSensor(buf, len, i));
            }
        }
    }
}
